
#include "ContextCash.h"
#include "CashNormal.h"
#include "CashRebate.h"
#include "CashReturn.h"

using namespace npStrategy;


//other constructors
ContextCash::ContextCash(CashType cashType)
{
    switch (cashType)
    {
    case CashType::NORMAL:
        this->cash = make_shared<CashNormal>();
        break;
    case CashType::REBATE:
        this->cash = make_shared<CashRebate>();
        break;
    case CashType::RETURN:
        this->cash = make_shared<CashReturn>();
    
    default:
        break;
    }
}

//public methods
double ContextCash::getCashResult(double money) throw(ErrorEnum)
{
    if (this->cash)
    {
        return this->cash->acceptCash(money);
    }
    else
    {
        throw ErrorEnum::NullCashStrategyException;
    }
}

//protected methods

//private methods

//static part

//others
